#include "Stddef.h"


int main()
{
	Init_Main();

	System_Test();


	while(1)
	{

		for(i=0;i<5;i++)
		{
			ADMUX = i | ( 0 << ADLAR);
			ADCSRA |= (1 << ADSC);
	
			while(! (ADCSRA & 0x10) );
			adc_input[i] = ADC;		

			if(mode==1)	
				ADC_Mm(i);

			ADC_rgu(i);	

			Uart_S16Bit_PutNum(adc_cal[i] , 1 );
			Uart_Print( "\t", 1 );
		}	
		
		Uart_Print("\n",1);
		_delay_ms(50);	
		
		if(mode>=2)
		{
			sbi(DDRE, 3);
			sbi(DDRE, 4); // Timer/Counter : 3  SET
	
			sbi(DDRB, 5);
			sbi(DDRB, 6);
			sbi(DDRB, 7); // Timer/Counter : 1 SET
		}	
		
		OCR1A = 50;
		OCR1B = 50;
		OCR1C = 50;
	
		OCR3A = 31+adc_cal[0];	
		OCR3B = 50;
	}

	return 0;
}


void Init_Main(void)
{
	cli();

	Uart_Init(16000000, 57600, 1);
	Init_Adc();
	Init_PWM();

	Init_INTERRUPT();

	sei();
}


void System_Test(void)
{
	Uart_Print( "Uart ch1 Test ok~!!", 1);


	_delay_ms(10);
}

